package cn.wolfcode.luowowo.controller;

import cn.wolfcode.luowowo.domain.TravelComment;
import cn.wolfcode.luowowo.query.TravelCommentQuery;
import cn.wolfcode.luowowo.service.ITravelCommentService;
import cn.wolfcode.luowowo.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("travelComment")
public class TravelCommentController {
    @Autowired
    private ITravelCommentService travelCommentService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")TravelCommentQuery qo) {
        Page<TravelComment> page = travelCommentService.query(qo);
        model.addAttribute("page", page);
        return "travelComment/list";
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(String id) {
        travelCommentService.delete(id);
        return JsonResult.success();
    }
}
